package com.woniu.map.service.impl;

import com.woniu.internalcommon.constant.CommonStatusEnum;
import com.woniu.internalcommon.dto.ResponseResult;
import com.woniu.internalcommon.response.DirectionResponse;
import com.woniu.map.remote.MapDirectionClient;
import com.woniu.map.service.DirectionService;
import jakarta.annotation.Resource;
import org.springframework.stereotype.Service;

@Service
public class DirectionServiceImpl implements DirectionService {
    @Resource
    private MapDirectionClient mapDirectionClient;
    /**
     * 根据出发点精度纬度 和目的地精度纬度 获取路线规划
     *
     * @param depLongitude
     * @param depLatitude
     * @param destLongitude
     * @param destLatitude
     * @return
     */
    @Override
    public ResponseResult driving(String depLongitude,
                                  String depLatitude,
                                  String destLongitude,
                                  String destLatitude) {
        DirectionResponse direction = mapDirectionClient.getDirection
                (depLongitude, depLatitude, destLongitude, destLatitude);
        if (direction == null) {
            return ResponseResult.fail(CommonStatusEnum.MAP_DISTRICT_ERROR.getCode(),
                    "无法获取路距离经纬度不正确");
        }else
            return ResponseResult.success(direction);
    }
}
